<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="/static/layui/css/layui.css"  media="all">
</head>
<body>

  <div style="padding: 10px;">

    <div class="layui-fluid">
      <form class="layui-form" id="ajaxform" onsubmit="return false">
        <input type="hidden" name="id" value="{$id ?? ''}">
        <div class="layui-form-item">
        <label class="layui-form-label">登录名</label>
        <div class="layui-input-block">
          <input name="name" required="" lay-verify="required" placeholder="请输入登录名" autocomplete="off" class="layui-input" type="text" value="{$data.name ?? ''}">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
          <input name="password" lay-verify="required" placeholder="编辑是不修改放空" autocomplete="off" class="layui-input" type="text" value="">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">权限名称</label>
        <div class="layui-input-block">
          <input name="remark" required="" lay-verify="required" placeholder="请输入权限名称" autocomplete="off" class="layui-input" type="text" value="{$data.remark ?? ''}">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">whatsapp</label>
        <div class="layui-input-block">
          <input name="kf1" required="" lay-verify="required" placeholder="请输入客服联系方式链接" autocomplete="off" class="layui-input" type="text" value="{$data.kf1 ?? ''}">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">telegram</label>
        <div class="layui-input-block">
          <input name="kf2" required="" lay-verify="required" placeholder="请输入客服联系方式链接" autocomplete="off" class="layui-input" type="text" value="{$data.kf2 ?? ''}">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">群组地址</label>
        <div class="layui-input-block">
          <input name="kf3" required="" lay-verify="required" placeholder="请输入群组地址链接" autocomplete="off" class="layui-input" type="text" value="{$data.kf3 ?? ''}">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">等级</label>
        <div class="layui-input-inline">
          <select class="layui-input" name='level' id='level'>
            {if condition="$data.level == 1"} <option value="1" selected="">总后台</option>
            {else /} <option value="1">总后台</option>
            {/if}
            {if condition="$data.level == 2"} <option value="1" selected="">业务经理</option>
            {else /} <option value="2">业务经理</option>
            {/if}
            {if condition="$data.level == 3"} <option value="1" selected="">业务组长</option>
            {else /} <option value="3">业务组长</option>
            {/if}
            {if condition="$data.level == 4"} <option value="1" selected="">业务员</option>
            {else /} <option value="4">业务员</option>
            {/if}
          </select>
        </div>
        <div class="layui-form-mid layui-word-aux">请选择管理员等级</div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">展示数据UID</label>
        <div class="layui-input-block">
          <input name="data_uid" required="" lay-verify="required" placeholder="请输入展示数据UID" autocomplete="off" class="layui-input" type="text" value="{$data.data_uid ?? 0}" >
        </div>
      </div>

      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="layui-btn" lay-filter="formDemo" onclick="ajax()">提交</button>
        </div>
      </div>
      </form>
    </div>   
  </div>     
<script src="/static/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script src="/static/js/jquery.min.js"></script>
  <script>
    //JavaScript代码区域
    layui.use(['element','form'], function(){
      var element = layui.element;
      var form = layui.form; 
    });

  function ajax(){
    layer.closeAll();
    var post_data = $("#ajaxform").serialize();
    // post_data = JSON.stringify(post_data);
    // console.log(post_data);
    $.ajax({
            url:"{:url('admin/Admin/add')}",
            type:"POST",
            data:post_data,
            success:function(ret){
                if (ret.code == 0) {
                  layer.msg('操作成功');
                    //layer.close(layer.index);
                    window.parent.location.reload();
                }
                if (ret.code == 1) {
                    layer.msg(ret.msg);
                }
            }
        });
  }
  </script>
</body>
</html>